<?php

namespace App\Jobs;

use App\Jobs\SendCami;
use App\Models\Mysql\XnOrder;
use App\Models\XnBatchOrder;
use App\Recharge\Service\ReturnSuccessOrFailure;
use Exception;
use Illuminate\Bus\Queueable;
use App\Models\Admin\Supplier;
use Illuminate\Support\Facades\Log;
use Illuminate\Queue\SerializesModels;
use App\Recharge\Service\CycleService;
use App\Recharge\Traits\RechargeTraits;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Recharge\Service\DirectChargingService;
use App\Jobs\Middleware\SupplierDbConnectCheck;
use App\Recharge\Service\CombinationProductsService;
use Throwable;


class ApiRechargeJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, RechargeTraits;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(public XnBatchOrder $order){}

    /**
     * 充值
     *
     * @return void
     */
    public function handle(): void
    {
        try {
              CombinationProductsService::new($this->order)->execute();
        } catch (Throwable $e) {
            Log::channel('job')->error($e->getMessage(), [
                'order'    => $this->order->toArray(),
            ]);
        }
    }
}

